<?php

namespace app\admin\controller;

use app\admin\service\DataCenterService;

/**
 *
 * 数据中心-BI大屏-控制器
 * Class DeviceBind
 */
class DataCenter extends Backend
{
    public function initialize()
    {
        parent::initialize();
        $this->service = new DataCenterService($this->request->get('schoole_id'),$this->userId);
    }

    /**
     * 获取平台基本信息
     * @return mixed|null
     */
    public function index()
    {
        $result = $this->service->getBaseInfo();
        return $this->jsonReturn($result);
    }

    /**
     * 获取今日学生出勤信息
     * @return null
     */
    public function getTodayAttendance()
    {
        $result = $this->service->getTodayAttendance();
        return $this->jsonReturn($result);
    }

    /**
     * 获取学生报警列表
     * @return null
     */
    public function getStudentResortList()
    {
        $page = $this->request->get('page', 1);
        $page_size = $this->request->get('page_size', 10);
        $result = $this->service->getStudentResortList($page, $page_size);
        return $this->jsonReturn($result);
    }

    /**
     * 获取学生报警统计
     * @return null
     */
    public function getStudentResortTotal()
    {
        $result = $this->service->getStudentResortTotal();
        return $this->jsonReturn($result);
    }

    /**
     * 获取今日各年级平均出勤率
     * @return null
     */
    public function getTodayGradeAttendance()
    {
        $result = $this->service->getTodayGradeAttendance();
        return $this->jsonReturn($result);
    }

    /**
     * 获取当日学生体温/心率监测数据
     * @return null
     */
    public function getTodayMonitor()
    {
        $result = $this->service->getTodayMonitor();
        return $this->jsonReturn($result);
    }

    /**
     * 获取各年级平均周/月/年出勤率统计
     * @return null
     */
    public function getTotalGradeAttendance()
    {
        $result = $this->service->getTotalGradeAttendance();
        return $this->jsonReturn($result);
    }

    /**
     * 获取学校当日设备在线分布
     * @return null
     */
    public function getTodayDeviceDistribution()
    {
        $result = $this->service->getTodayDeviceDistribution();
        return $this->jsonReturn($result);
    }
}
